package com.sservice.web.wechat.service;

import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import com.sservice.base.StringUtils;
import com.sservice.web.wechat.config.WxPayProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;


/**
 * Created by suweiming on 2017/12/20.
 */


@Service("wxPayService")
public class WxPayService extends WxPayServiceImpl {
    Logger logger = LoggerFactory.getLogger(WxPayService.class);

    public WxPayConfig config() {
        WxPayConfig payConfig = new WxPayConfig();
        payConfig.setAppId(WxPayProperties.appId);
        payConfig.setMchId(WxPayProperties.mchId);
        payConfig.setMchKey(WxPayProperties.mchKey);
        payConfig.setSubAppId(StringUtils.trimToNull(WxPayProperties.subAppId));
        payConfig.setSubMchId(StringUtils.trimToNull(WxPayProperties.subMchId));
        payConfig.setKeyPath(WxPayProperties.keyPath);
        return payConfig;
    }
    public WxPayService() {
        WxPayConfig wpc = config();
        setConfig(wpc);
        logger.debug("[=======]init");
    }
}
